package delete;

public class Solution {
    public static int removeDuplicates(int[] nums) {
        int lastIndex = nums.length;

        int frontIndex = nums[0];
        int j = 0;
        for (int i = 1; i < lastIndex; i++) {
            j = i;
            while(j < lastIndex) {
                if (nums[j] == frontIndex) {

                    for (int k = j; k < lastIndex - 1; k++) {
                        nums[k] = nums [k+1];
                    }
                    --lastIndex;
                }
                j++;
            }
            frontIndex = nums[i];
        }

//        for (int i = 1; i < lastIndex + 1; i++) {
//            for (int j = i; j < lastIndex + 1; j++) {
//                if (frontIndex == nums[j]) {
//                    if (nums[lastIndex] != frontIndex) {
//                        nums[j] = nums[lastIndex];
//                        lastIndex--;
//                    } else {
//                        lastIndex--;
//                        i--;
//                    }
//                }
//            }
//            frontIndex = nums[i];
//        }
        return lastIndex;
    }
}

class Ts {
    public static void main(String[] args) {
        int[] nums = new int[]{0,0,1,1,1,2,2,3,3,4};
        int ret = Solution.removeDuplicates(nums);
        System.out.println(ret);
    }
}